package com.hefei.blog.web.common.utils;

import java.util.List;

import org.apache.log4j.Logger;

import com.hefei.common.util.ConfigLineReader;

public class LoginInclude {
	private static final Logger log = Logger.getLogger(LoginInclude.class);
	
	private static final AntPathMatcher matche = new AntPathMatcher();
	private static final String LOGIN_EXCLUDE_FILE = "/loginfilter-include.properties";
	private static List<String> includes = null;
	
	public static boolean matchIncludes(String url){
		if(includes == null || includes.isEmpty())
			return false;
		for(String pattern : includes){
			if(matche.match(pattern, url)){
				return true;
			}
		}
		return false;
	}
	
	public static void init() {
		ConfigLineReader configLineReader = ConfigLineReader.read(LOGIN_EXCLUDE_FILE);
		includes = configLineReader.getLines();
		log.info(" all url:" + includes);
	}
	
	public static void main(String[] args){
		LoginInclude.init();
	}
}
